<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>视频列表</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
</head>
<body>
    <div id="videoTable" class="layui-row layui-col-space10"></div>


    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/layui/layui.js"></script>
    <script>
        $(function () {
            var tid = loadUrl();
            loadAllVideo(tid);
        });

        function loadUrl(){
            var url = location.search;
            var tid = url.substring(url.lastIndexOf("=")+1);
            return tid;
        }

        function loadAllVideo(tid){
            $.ajax({
                type:"post",
                url:"${pageContext.request.contextPath}/selectVideoByTid.do",
                data:{tid:tid},
                dataType:"json",
                success:function(result){
                    if(result.status){
                        $("#videoTable").empty();
                        var list = result.data;
                        var html = '';
                        for(var i = 0;i < list.length;i++){
                            html += '<div class="layui-col-md3">';
                                html += '<div class="layui-panel">';
                                    html += '<div style="padding: 30px;"><img style="width:160px;height:60px;" src="'+list[i].coverImgAddress+'"></div>';
                                    html += '<div style="padding: 30px;">' +
                                                '<a href="player.jsp?vid='+list[i].vid+'">电影名:'+list[i].vName+'</a>' +
                                            '</div>';
                                html += '</div>';
                            html += '</div>';
                        }
                        $("#videoTable").append(html);
                    }else{
                        alert(result.message);
                    }
                }
            });
        }

        <%--'<a href="javascript:videoIsVip(\''+list[i].vid+'\')">电影名:'+list[i].vName+'</a>' +
        function videoIsVip(vid){--%>
        <%--    $.ajax({--%>
        <%--        type:"post",--%>
        <%--        url:"${pageContext.request.contextPath}/videoIsPlayer.do",--%>
        <%--        data:{vid:vid},--%>
        <%--        dataType:"json",--%>
        <%--        success:function(result){--%>
        <%--            if(result.status){--%>
        <%--                location.href = "player?vid="+vid;--%>
        <%--            }else{--%>
        <%--                alert(result.message);--%>
        <%--            }--%>
        <%--        }--%>
        <%--    });--%>
        <%--}--%>
    </script>
</body>
</html>
